using Brouteforce.UserInterface.Abstracts;
using Microsoft.Xna.Framework;
using Brouteforce.Utilities;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Brouteforce.NewManagers
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class UIControlManager : Manager
    {
        public static UIControlManager Instance = new UIControlManager();

        public AbstractUIControl CurrentFocuseOn = null;
        public MonitoredProperty<AbstractUIControl> CurrentUIControl= new MonitoredProperty<AbstractUIControl>(null);

        public Texture2D GreyStoneTexture;
        public Texture2D BlackStoneTexture;
        public Texture2D CreateButtonTexture;
        public Texture2D SliderBackgroundTexture;
        public Texture2D SliderScrollBarTexture;
        public Texture2D PlayerTexture;
        
        public override void LoadContent(ContentManager content)
        {
            CreateButtonTexture = content.Load<Texture2D>("Textures/Buttons/create");
            GreyStoneTexture = content.Load<Texture2D>("Textures/grey-stone");
            BlackStoneTexture = content.Load<Texture2D>("Textures/black-stone");
            SliderBackgroundTexture = content.Load<Texture2D>("Textures/Slider/Slider-Background");
            SliderScrollBarTexture = content.Load<Texture2D>("Textures/Slider/Slider-ScrollBar");
            PlayerTexture = content.Load<Texture2D>("Player"); 
        }


        public override void Initialize()
        {
            //todo 
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void _Update(GameTime gameTime, BFGame game) {
       
            
            //todo check LastKnowedChangedLoopIndex
            //if (CurrentUIControl.IsChangedSince(ScreenManager.CurrentScreen.ChangedIn()))
            //{
                    
            //}
            //ScreenManager.CurrentScreen.Property.Update(gameTime);


          }


        public override void Draw(GameTime gameTime, BFGame game) {
        
        }

        public void ChangeFocousedUIControl(AbstractUIControl abstractUIControl)
        {
            if (CurrentFocuseOn != null )
                CurrentFocuseOn.RemoveFocus();

            if (abstractUIControl != null)
            {
                CurrentFocuseOn = abstractUIControl;
                CurrentFocuseOn.AddFocus();
            }
        }
    }
}
